import { reactive } from 'vue'

export const form = reactive({
  userForm: {
    oldPassword: null,
    newPasswordFirst: null,
    newPasswordSecond: null
  },
  userRules: {
    oldPassword: [{ required: true, message: '请输入旧密码', trigger: ['blur', 'input'] }],
    newPasswordFirst: [{ required: true, message: '请输入新密码', trigger: ['blur', 'input'] }],
    newPasswordSecond: [
      { required: true, message: '请再次输入密码', trigger: ['blur', 'input'] },
      { validator: validatePasswordSame, message: '两次密码输入不一致', trigger: ['input'] }
    ]
  },
  formItem: [
    { type: 'input', key: 'oldPassword', label: '旧密码', prop: { required: true, maxlength: '16', placeholder: '请输入终点名称', clearable: true }},
    { type: 'input', key: 'newPasswordFirst', label: '新密码', prop: { required: true, maxlength: '16', placeholder: '请输入终点名称', clearable: true }},
    { type: 'input', key: 'newPasswordSecond', label: '确认新密码', prop: { required: true, maxlength: '16', placeholder: '请输入终点名称', clearable: true }}
  ]
})
function validatePasswordSame(rule, value) {
  return value === form.userForm.newPasswordFirst
}

